package cn.itcast.service.impl;

import cn.itcast.dao.HospitalDao;
import cn.itcast.pojo.Address;
import cn.itcast.service.HospitalService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service(version = "1.0.0")
public class HospitalServiceImpl implements HospitalService {

    @Autowired
    private HospitalDao hospitalDao;

    @Override
    public List<Address> findHospital() {
        List<Address> addressList = hospitalDao.selecthospitalList();
        if (null == addressList) {
            return null;
        }
        return addressList;
    }

    @Override
    public void handleSubmit(Address address) {
        hospitalDao.insertHospital(address);
    }

    @Override
    public void update(Address address) {
        hospitalDao.updateHospital(address);
    }

    @Override
    public Integer yesOrNo(Integer enable, Integer id) {
        Address address = this.hospitalDao.selectOne(id);
        System.out.println(address);
        //1表示启用 ， 0表示禁用
        address.setEnable(enable);
        this.hospitalDao.updateHospital(address);

        Integer aaa = address.getEnable();
        return aaa;
    }

    @Override
    public Address selectById(Integer id) {
        Address address = this.hospitalDao.selectOne(id);
        return address;
    }

}
